FROM rust:1.74 as builder
WORKDIR /app

# RUN mkdir /root/.cargo \
#  && echo 'registry = "https://github.com/rust-lang/crates.io-index"' > /root/.cargo/config \
#  && echo 'replace-with = "ustc"' >> /root/.cargo/config \
#  && echo '[source.ustc]' >> /root/.cargo/config \
#  && echo 'registry = "git://mirrors.ustc.edu.cn/crates.io-index"' >> /root/.cargo/config 

COPY ./Cargo.toml ./Cargo.lock ./config.toml ./
COPY ./src ./src

RUN cargo build --release --locked 

RUN cargo build --release  

FROM ubuntu:24.04

WORKDIR /root/app
COPY --from=builder /app/target/release/. ./
COPY --from=builder /app/config.toml ./

CMD ["./app"]
